package com.caishi.lkx.exam.records.oss;

import com.aliyun.oss.model.CannedAccessControlList;
import com.zzw.common.AliyunConfig;
import com.zzw.common.file.OssConfig;
import com.zzw.common.file.OssPlugins;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration(proxyBeanMethods = false)
@ConfigurationProperties(prefix = "records.oss", ignoreUnknownFields = false)
@Getter
@Setter
public class RecordsOssConfig implements OssConfig {

    private String endpoint;

    private String extranetEndpoint;

    private String bucket;

    private String basePath;

    private String region;

    private Integer pollCount = 10;

    private Integer pollMax = 100;

    private CannedAccessControlList acl = CannedAccessControlList.Private;

    @Bean
    public OssPlugins recordsOssPlugins(@Qualifier("redisTemplate") RedisTemplate<String, String> redisTemplate) {
        AliyunConfig aliyunConfig = new AliyunConfig();
        aliyunConfig.setAccessKeyId("LTAI5tLwWVT15HeULoBzEtWG");
        aliyunConfig.setAccessKeySecret("arvzASVP6AtirjehCkqW0ckdJ2MNhm");
        return new OssPlugins(aliyunConfig, this, redisTemplate);
    }
}
